package com.lfk.demo.Ability;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.TextField;

import com.lfk.demo.ResourceTable;

public class EditAbility extends Ability {
    private TextField editText;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setPattern(ResourceTable.Pattern_base);
        setUIContent(ResourceTable.Layout_ability_edit);
        editText = (TextField)findComponentById(ResourceTable.Id_edittext);
        findComponentById(ResourceTable.Id_action_settings).setClickedListener(this::onActionSettings);
    }

    public void onActionSettings(Component component) {
        Intent intent = new Intent();
        Intent.OperationBuilder builder = new Intent.OperationBuilder()
                .withDeviceId("")
                .withBundleName(getBundleName())
                .withAbilityName(MarkDownAbility.class);
        intent.setParam("str", editText.getText());
        intent.setOperation(builder.build());
        startAbility(intent);
    }
}
